import { bg_image } from "./indoorConfig.js";
import {parkInsideRecordList,indoorRecordList,outdoorRecordList,} from "../api/payRecords/index.js"
export default {
	data() {
		return {
			bg_image,
			//月卡支付记录start
			list: [],
			status: 'more', //more/loading/noMore
			contentText: {
				contentdown: '查看更多',
				contentrefresh: '加载中',
				contentnomore: '没有更多'
			},
			query: {
				page: 1,
				pageSize: 10
			},
			//月卡支付记录end
			recordType: 0,
			//室内停车支付记录start
			orderList: [],
			orderStatus: 'more', //more/loading/noMore
			orderContentText: {
				contentdown: '查看更多',
				contentrefresh: '加载中',
				contentnomore: '没有更多'
			},
			orderQuery: {
				page: 1,
				pageSize: 10
			},
			//路侧停车支付记录start
			outdoorOrderList: [],
			outdoorOrderStatus: 'more', //more/loading/noMore
			outdoorOrderContentText: {
				contentdown: '查看更多',
				contentrefresh: '加载中',
				contentnomore: '没有更多'
			},
			outdoorOrderQuery: {
				page: 1,
				pageSize: 10
			},
		}
	},
	onLoad() {
		this.getList()
		this.getOrderList()
		this.getOutdoorOrderList()
	},
	methods: {
		async fetchSomething(query){
			this.query.page = 1
			this.outdoorOrderQuery.page = 1
			this.orderQuery.page = 1
			this.getList()
			this.getOrderList()
			this.getOutdoorOrderList()
		},
		go(url, params, type) {
			uni.navigateTo({
				url: `${url}?type=${type}&id=${params.id}`
			})
		},
		handleTab(val) {
			this.recordType = val
			if(val == 2) {
				this.query.page = 1
				this.getList()
			}else if(val == 1){
				this.outdoorOrderQuery.page = 1
				this.getOutdoorOrderList()
			}else{
				this.orderQuery.page = 1
				this.getOrderList()
			}
		},
		//月卡支付记录start
		async getList() {
			let res = await parkInsideRecordList(this.query)
			if(!res) return this.status = 'more'
			if(this.query.page == 1) this.list = []
			let data = res.data || {}
			this.query.page += 1
			let list = data.list || []
			this.list = [...this.list, ...list]
			if (list.length === 0) {
				this.status = 'noMore'
				return false;
			}
			this.status = 'more'
		},
		clickLoadMore(e) {
			this.status = 'loading'
			this.getList()
		},
		//月卡支付记录end
		//室内停车支付记录start
		async getOrderList() {
			let res = await indoorRecordList(this.orderQuery)
			if(!res) return this.orderStatus = 'more'
			if(this.orderQuery.page == 1) this.orderList = []
			let data = res.data || {}
			this.orderQuery.page += 1
			let list = data.list || []
			this.orderList = [...this.orderList, ...list]
			if (list.length === 0) {
				this.orderStatus = 'noMore'
				return false;
			}
			this.orderStatus = 'more'
		},
		clickOrderLoadMore(e) {
			this.orderStatus = 'loading'
			this.getOrderList()
		},
		//路侧石停车支付记录
		async getOutdoorOrderList() {
			let res = await outdoorRecordList(this.outdoorOrderQuery)
			if(!res) return this.outdoorOrderStatus = 'more'
			if(this.outdoorOrderQuery.page == 1) this.outdoorOrderList = []
			let data = res.data || {}
			this.outdoorOrderQuery.page += 1
			let list = data.list || []
			this.outdoorOrderList = [...this.outdoorOrderList, ...list]
			if (list.length === 0) {
				this.outdoorOrderStatus = 'noMore'
				return false;
			}
			this.outdoorOrderStatus = 'more'
		},
		clickOutdoorOrderLoadMore(e) {
			this.outdoorOrderStatus = 'loading'
			this.getOutdoorOrderList()
		}
	}
}